import i18n from '@/i18n'
import { hasPermission } from '@/utils'
import { RenderName,  RenderBotNumber, RenderReportNumber, RenderChart, RenderLinkedBotsAction, RenderJira, RenderStatus, RenderBussinessType, RenderTimeFormat } from './element'


export const renderColumns = () => [
  {
    field: 'name',
    headerText: i18n.t('custom.reports.name'),
    width: 250,
    clipMode: 'EllipsisWithTooltip',
    template: RenderName
  },
  // {
  //   headerText: i18n.t('handle'),
  //   width: 270,
  //   textAlign: 'Center',
  //   template: RenderAction
  // },
  {
    field: 'chartType',
    headerText: i18n.t('custom.accounting.gadgetType'),
    width: 120,
    textAlign: 'Center',
    template: RenderChart
  },
  {
    field: 'description',
    headerText: i18n.t('custom.accounting.description'),
    width: 150,
    clipMode: 'EllipsisWithTooltip'
  },
  {
    field: 'client',
    headerText: i18n.t('custom.reports.client'),
    width: 100,
    clipMode: 'EllipsisWithTooltip',
    visible: hasPermission('sys:reports:internalNotes')
  },
  {
    field: 'assignee',
    headerText: i18n.t('custom.reports.assignee'),
    width: 120,
    clipMode: 'EllipsisWithTooltip',
    visible: hasPermission('sys:reports:internalNotes')
  },
  {
    headerText: i18n.t('custom.reports.integration'),
    width: 130,
    field: 'integrations',
    clipMode: 'EllipsisWithTooltip'
  },
  {
    field: 'businessType',
    headerText: i18n.t('custom.reports.businessType'),
    width: 100,
    template: RenderBussinessType
  },
  {
    field: 'status',
    headerText: i18n.t('custom.widget.status'),
    width: 100,
    template: RenderStatus
  },
  {
    field: 'reportNum',
    headerText: i18n.t('custom.widget.linkedbtn'),
    width: 160,
    textAlign: 'Center',
    template: RenderReportNumber
  },
  {
    field: 'botNum',
    headerText: i18n.t('custom.dataset.linkedbotbtn'),
    width: 160,
    textAlign: 'Center',
    template: RenderBotNumber
  },
  {
    field: 'creatorName',
    headerText: i18n.t('custom.widget.creator'),
    width: 100

  },
  {
    field: 'createDate',
    headerText: i18n.t('custom.widget.createddate'),
    width: 180,
    format: (value) => timeFormat(value)

  },
  {
    field: 'updateByName',
    headerText: i18n.t('custom.widget.lastupdatedby'),
    width: 150
  },
  {
    field: 'updateDate',
    headerText: i18n.t('custom.reports.updateDate'),
    width: 170,
    format: (value) => timeFormat(value)

  },
  {
    field: 'jiraNumber',
    headerText: i18n.t('custom.reports.jiraNumber'),
    width: 120,
    clipMode: 'EllipsisWithTooltip',
    template: RenderJira,
    visible: hasPermission('sys:reports:internalNotes')
  },
  {
    field: 'poName',
    headerText: i18n.t('custom.reports.poName'),
    width: 80,
    clipMode: 'EllipsisWithTooltip',
    visible: hasPermission('sys:reports:internalNotes')
  },
  {
    field: 'daName',
    headerText: i18n.t('custom.reports.daName'),
    width: 80,
    clipMode: 'EllipsisWithTooltip',
    visible: hasPermission('sys:reports:internalNotes')
  }
]

export const renderDashboardWidgetColumns = () => Object.freeze([
  {
    field: 'name',
    headerText: i18n.t('custom.dataset.name'),
    width: 140,
    clipMode: 'EllipsisWithTooltip'
  },
  {
    field: 'businessType',
    headerText: i18n.t('custom.dataset.businessType'),
    width: 70
  },
  {
    field: 'status',
    headerText: i18n.t('custom.dataset.status'),
    width: 70
  },
  {
    field: 'updateDate',
    headerText: i18n.t('custom.reports.updateDate'),
    width: 100,
    template: RenderTimeFormat
  },
  {
    width: 70,
    commands: [
      {
        type: 'View',
        buttonOption: {
          content: i18n.t('custom.reports.viewbtn'),
          cssClass: 'e-outline e-small e-primary'
        }
      }
    ]
  }
])
